package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.enums.DemandStatus;
import com.weipai.springboot.model.Demand;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.dao.DemandDao;
import com.weipai.springboot.module.mapper.DemandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/27 10:28
 */
@Repository
public class DemandDaoImpl implements DemandDao {

    @Autowired
    DemandMapper demandMapper;

    @Override
    public int save(Demand demand) {
        return demandMapper.insert(demand);
    }

    @Override
    public List<Demand> selectAllByDemand(String demandCategoryId) {
        return demandMapper.selectAllByDemand(demandCategoryId);
    }

    @Override
    public Demand getDemandById(String id) {
        return demandMapper.getDemandById(id);
    }

    @Override
    public List<Demand> selectDemandByStatus(Integer demandStatus, int i, Integer size) {
        return demandMapper.selectDemandByStatus(demandStatus, i, size);
    }

    @Override
    public Integer countDemandByStatus(Integer demandStatus) {
        return demandMapper.countDemandByStatus(demandStatus);
    }

    //需求列表
    @Override
    public List<Map<String, Object>> demandListByCity(Integer start, Integer size,  Integer status) {
        return demandMapper.demandListByCity(start, size,  status);
    }

    //需求总数量
    @Override
    public Integer demandListAmountByCity( Integer status) {
        return demandMapper.demandListAmountByCity(status);
    }

    @Override
    public List<Map<String, Object>> demandListByCustomer(Integer start, Integer size, String customerId, Integer status) {
        return demandMapper.demandListByCustomer(start, size, customerId, status);
    }

    @Override
    public List<Map<String, Object>> demandListByArtisanId(Integer start, Integer size, String artisanId, Integer status) {
        return demandMapper.demandListByArtisanId22(start, size, artisanId, status);
    }

    @Override
    public Integer demandListAmountByCustomer(String customerId, Integer status) {
        return demandMapper.demandListAmountByCustomer(customerId, status);
    }

    @Override
    public Integer demandListAmountByArtisanId(String artisanId, Integer status) {
        return demandMapper.demandListAmountByArtisanId(artisanId, status);
    }

    //更改需求的状态
    @Override
    public int updateStatus(String id, Integer status) {
        return demandMapper.updateStatus(id, status);
    }

    @Override
    public int update(Demand demand) {
        return demandMapper.updateByPrimaryKeySelective(demand);
    }

    @Override
    public List<Demand> demandListByArtisanId(String artisanId, Integer status) {
        return demandMapper.demandListByArtisanId(artisanId, status);
    }

    //按月份和需求订单状态分组查出每个月各个订单的数量
    @Override
    public List<Map<String, Object>> demandStatement(String time, String demandCategoryId) {
        return demandMapper.demandStatement(time, demandCategoryId);
    }

    //每个分类下的订单数量
    public List<Map<String, Object>> getDemandCountList(String time, int demandStatus) {
        return demandMapper.getDemandCountList(time, demandStatus);
    }

    //技工的订单数
    @Override
    public Integer getDemandAmountByArtisan(String artisanId, Integer status) {
        return demandMapper.getDemandAmountByArtisan(artisanId, status);
    }

    //通过需求订单号查询需求订单
    @Override
    public Map<String, Object> getDemandInfoByDemandNumber(String demandNumber) {
        return demandMapper.getDemandInfoByDemandNumber(demandNumber);
    }

    //通过需求订单号查询需求对象
    @Override
    public Demand getDemandByDemandNumber(String orderNumber) {
        return demandMapper.getDemandByDemandNumber(orderNumber);
    }

    //更改需求订单为交易成功
    @Override
    public int updatePayStatus(String orderNumber, Integer payment, int status) {
        return demandMapper.updatePayStatus(orderNumber, payment, status);
    }

    //根据需求订单状态查询订单
    @Override
    public List<Map<String, Object>> getDemandByDemandStatus(int demandStatus) {
        return demandMapper.getDemandByDemandStatus(demandStatus);
    }


    @Override
    public List<Map<String, Object>> getDemandByArtisan(String id) {
        return demandMapper.getDemandByArtisan(id);
    }
}
